<?php
define("EW_PAGE_ID", "add", TRUE); // Page ID
define("EW_TABLE_NAME", 'osj-resumes', TRUE);
?>
<?php 
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "osj-ewcfg50.php" ?>
<?php include "osj-ewmysql50.php" ?>
<?php include "osj-phpfn50.php" ?>
<?php include "osj-osj2dresumesinfo.php" ?>
<?php include "osj-userfn50.php" ?>
<?php include "osj-osj2dusersinfo.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Open connection to the database
$conn = ew_Connect();
?>
<?php
$Security = new cAdvancedSecurity();
?>
<?php
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
$Security->LoadCurrentUserLevel('osj-resumes');
if (!$Security->IsLoggedIn()) {
	$Security->SaveLastUrl();
	Page_Terminate("osj-login.php");
}
if (!$Security->CanAdd()) {
	$Security->SaveLastUrl();
	Page_Terminate("osj-osj2dresumeslist.php");
}
if ($Security->IsLoggedIn() && $Security->CurrentUserID() == "") {
	$_SESSION[EW_SESSION_MESSAGE] = "You do not have the right permission to view the page";
	Page_Terminate("osj-login.php");
}
?>
<?php

// Common page loading event (in userfn*.php)
Page_Loading();
?>
<?php

// Page load event, used in current page
Page_Load();
?>
<?php
$osj2Dresumes->Export = @$_GET["export"]; // Get export parameter
$sExport = $osj2Dresumes->Export; // Get export parameter, used in header
$sExportFile = $osj2Dresumes->TableVar; // Get export file, used in header
?>
<?php

// Load key values from QueryString
$bCopy = TRUE;
if (@$_GET["resume_id"] != "") {
  $osj2Dresumes->resume_id->setQueryStringValue($_GET["resume_id"]);
} else {
  $bCopy = FALSE;
}

// Create form object
$objForm = new cFormObj();

// Process form if post back
if (@$_POST["a_add"] <> "") {
  $osj2Dresumes->CurrentAction = $_POST["a_add"]; // Get form action
  GetUploadFiles(); // Get upload files
  LoadFormValues(); // Load form values
} else { // Not post back
  if ($bCopy) {
    $osj2Dresumes->CurrentAction = "C"; // Copy Record
  } else {
    $osj2Dresumes->CurrentAction = "I"; // Display Blank Record
    LoadDefaultValues(); // Load default values
  }
}

// Perform action based on action code
switch ($osj2Dresumes->CurrentAction) {
  case "I": // Blank record, no action required
		break;
  case "C": // Copy an existing record
   if (!LoadRow()) { // Load record based on key
      $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
      Page_Terminate($osj2Dresumes->getReturnUrl()); // Clean up and return
    }
		break;
  case "A": // ' Add new record
		$osj2Dresumes->SendEmail = TRUE; // Send email on add success
    if (AddRow()) { // Add successful
      $_SESSION[EW_SESSION_MESSAGE] = "Add New Record Successful"; // Set up success message
      Page_Terminate($osj2Dresumes->KeyUrl($osj2Dresumes->getReturnUrl())); // Clean up and return
    } else {
      RestoreFormValues(); // Add failed, restore form values
    }
}

// Render row based on row type
$osj2Dresumes->RowType = EW_ROWTYPE_ADD;  // Render add type
RenderRow();
?>
<?php include "osj-header.php" ?>
<script type="text/javascript">
<!--
var EW_PAGE_ID = "add"; // Page id
var EW_SHOW_HIGHLIGHT = "Show highlight"; 
var EW_HIDE_HIGHLIGHT = "Hide highlight";

//-->
</script>
<script type="text/javascript">
<!--

function ew_ValidateForm(fobj) {
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_resume_permissions_id"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Resume Status Level"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_resume_text"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Resume Text"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_resume_file"];
		aelm = fobj.elements["a" + infix + "_resume_file"];
		var chk_resume_file = (aelm && aelm[0])?(aelm[2].checked):true;
		if (elm && chk_resume_file && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Resume Attachment"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_resume_file"];
		if (elm && !ew_CheckFileType(elm.value)) { 
			if (!ew_OnError(elm, "File type is not allowed.")) 
				return false; 
		}
		elm = fobj.elements["x" + infix + "_resume_categories"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Resume Categories"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_resume_title"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Resume Title"))
				return false;
		}
	}
	return true;
}

//-->
</script>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
<!--
_width_multiplier = 16;
_height_multiplier = 60;
var ew_DHTMLEditors = [];

function ew_UpdateTextArea() {
	if (typeof ew_DHTMLEditors != 'undefined' &&
		typeof FCKeditorAPI != 'undefined') {			
			var inst;			
			for (inst in FCKeditorAPI.__Instances)
				FCKeditorAPI.__Instances[inst].UpdateLinkedField();
	}
}

//-->
</script>
<script type="text/javascript">
<!--

// js for Popup Calendar
//-->

</script>
<script type="text/javascript">
<!--
var ew_MultiPagePage = "Page"; // multi-page Page Text
var ew_MultiPageOf = "of"; // multi-page Of Text
var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
var ew_MultiPageNext = "Next"; // multi-page Next Text

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker">Add to TABLE: Resumes<br><br><a href="<?php echo $osj2Dresumes->getReturnUrl() ?>">Go Back</a></span></p>
<?php
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Mesasge in Session, display
?>
<p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
<?php
  $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
}
?>
<form name="fosj2Dresumesadd" id="fosj2Dresumesadd" action="osj-osj2dresumesadd.php" method="post" enctype="multipart/form-data">
<p>
<input type="hidden" name="a_add" id="a_add" value="A">
<table class="ewTable">
  <tr class="ewTableRow">
    <td class="ewTableHeader">Resume Status Level<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $osj2Dresumes->resume_permissions_id->CellAttributes() ?>><span id="cb_x_resume_permissions_id">
<select id="x_resume_permissions_id" name="x_resume_permissions_id"<?php echo $osj2Dresumes->resume_permissions_id->EditAttributes() ?>>
<!--option value="">Please Select</option-->
<?php
if (is_array($osj2Dresumes->resume_permissions_id->EditValue)) {
	$arwrk = $osj2Dresumes->resume_permissions_id->EditValue;
	$rowswrk = count($arwrk);
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($osj2Dresumes->resume_permissions_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";	
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
			}
}
?>
</select>
</span></td>
  </tr>
<input type="hidden" name="x_resume_edit_date" id="x_resume_edit_date" value="<?php echo ew_HtmlEncode($osj2Dresumes->resume_edit_date->CurrentValue) ?>">
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">Resume Text<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $osj2Dresumes->resume_text->CellAttributes() ?>><span id="cb_x_resume_text">
<textarea name="x_resume_text" id="x_resume_text" cols="35" rows="4"<?php echo $osj2Dresumes->resume_text->EditAttributes() ?>><?php echo $osj2Dresumes->resume_text->EditValue ?></textarea>
<script type="text/javascript">
<!--
var editor = new ew_DHTMLEditor("x_resume_text");
editor.create = function() {
	var sBasePath = 'fckeditor/';
	var oFCKeditor = new FCKeditor('x_resume_text', 35*_width_multiplier, 4*_height_multiplier);
	oFCKeditor.BasePath = sBasePath;
	oFCKeditor.ReplaceTextarea();
	this.active = true;
}
ew_DHTMLEditors[ew_DHTMLEditors.length] = editor;
-->
</script>
</span></td>
  </tr>
  <tr class="ewTableRow">
    <td class="ewTableHeader">Resume Attachment<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $osj2Dresumes->resume_file->CellAttributes() ?>><span id="cb_x_resume_file">
<input type="file" name="x_resume_file" id="x_resume_file"  size="30"<?php echo $osj2Dresumes->resume_file->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">Resume Categories<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $osj2Dresumes->resume_categories->CellAttributes() ?>><span id="cb_x_resume_categories">
</span></td>
  </tr>
  <tr class="ewTableRow">
    <td class="ewTableHeader">Resume Title<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $osj2Dresumes->resume_title->CellAttributes() ?>><span id="cb_x_resume_title">
<input type="text" name="x_resume_title" id="x_resume_title"  size="30" maxlength="255" value="<?php echo $osj2Dresumes->resume_title->EditValue ?>"<?php echo $osj2Dresumes->resume_title->EditAttributes() ?>>
</span></td>
  </tr>
</table>
<p>
<input type="button" name="btnAction" id="btnAction" value="    Add    " onClick="ew_SubmitForm(this.form);">
</form>
<script type="text/javascript">
<!--
ew_CreateEditor();  // Create DHTML editor(s)

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "osj-footer.php" ?>
<?php

// If control is passed here, simply terminate the page without redirect
Page_Terminate();

// -----------------------------------------------------------------
//  Subroutine Page_Terminate
//  - called when exit page
//  - clean up connection and objects
//  - if url specified, redirect to url, otherwise end response
function Page_Terminate($url = "") {
	global $conn;

	// Page unload event, used in current page
	Page_Unload();

	// Global page unloaded event (in userfn*.php)
	Page_Unloaded();

	 // Close Connection
	$conn->Close();

	// Go to url if specified
	if ($url <> "") {
		ob_end_clean();
		header("Location: $url");
	}
	exit();
}
?>
<?php

// Function Get upload files
function GetUploadFiles() {
	global $objForm, $osj2Dresumes;

	// Get upload data
		if ($osj2Dresumes->resume_file->Upload->UploadFile()) {

			// No action required
		} else {
			echo $osj2Dresumes->resume_file->Upload->Message;
			exit();
		}
}
?>
<?php

// Load default values
function LoadDefaultValues() {
	global $osj2Dresumes;
	$osj2Dresumes->user_id->CurrentValue = 0;
	$osj2Dresumes->resume_permissions_id->CurrentValue = 0;
	$osj2Dresumes->resume_creation_date->CurrentValue = "0000-00-00 00:00:00";
	$osj2Dresumes->resume_edit_date->CurrentValue = "CURRENT_TIMESTAMP";
}
?>
<?php

// Load form values
function LoadFormValues() {

	// Load from form
	global $objForm, $osj2Dresumes;
	$osj2Dresumes->user_id->setFormValue($objForm->GetValue("x_user_id"));
	$osj2Dresumes->resume_permissions_id->setFormValue($objForm->GetValue("x_resume_permissions_id"));
	$osj2Dresumes->resume_creation_date->setFormValue($objForm->GetValue("x_resume_creation_date"));
	$osj2Dresumes->resume_creation_date->CurrentValue = ew_UnFormatDateTime($osj2Dresumes->resume_creation_date->CurrentValue, 10);
	$osj2Dresumes->resume_edit_date->setFormValue($objForm->GetValue("x_resume_edit_date"));
	$osj2Dresumes->resume_edit_date->CurrentValue = ew_UnFormatDateTime($osj2Dresumes->resume_edit_date->CurrentValue, 10);
	$osj2Dresumes->resume_text->setFormValue($objForm->GetValue("x_resume_text"));
	$osj2Dresumes->resume_categories->setFormValue($objForm->GetValue("x_resume_categories"));
	$osj2Dresumes->resume_title->setFormValue($objForm->GetValue("x_resume_title"));
}

// Restore form values
function RestoreFormValues() {
	global $osj2Dresumes;
	$osj2Dresumes->user_id->CurrentValue = $osj2Dresumes->user_id->FormValue;
	$osj2Dresumes->resume_permissions_id->CurrentValue = $osj2Dresumes->resume_permissions_id->FormValue;
	$osj2Dresumes->resume_creation_date->CurrentValue = $osj2Dresumes->resume_creation_date->FormValue;
	$osj2Dresumes->resume_creation_date->CurrentValue = ew_UnFormatDateTime($osj2Dresumes->resume_creation_date->CurrentValue, 10);
	$osj2Dresumes->resume_edit_date->CurrentValue = $osj2Dresumes->resume_edit_date->FormValue;
	$osj2Dresumes->resume_edit_date->CurrentValue = ew_UnFormatDateTime($osj2Dresumes->resume_edit_date->CurrentValue, 10);
	$osj2Dresumes->resume_text->CurrentValue = $osj2Dresumes->resume_text->FormValue;
	$osj2Dresumes->resume_categories->CurrentValue = $osj2Dresumes->resume_categories->FormValue;
	$osj2Dresumes->resume_title->CurrentValue = $osj2Dresumes->resume_title->FormValue;
}
?>
<?php

// Load row based on key values
function LoadRow() {
	global $conn, $Security, $osj2Dresumes;
	$sFilter = $osj2Dresumes->SqlKeyFilter();
	if (!is_numeric($osj2Dresumes->resume_id->CurrentValue)) {
		return FALSE; // Invalid key, exit
	}
	$sFilter = str_replace("@resume_id@", ew_AdjustSql($osj2Dresumes->resume_id->CurrentValue), $sFilter); // Replace key value
	if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
		$sFilter = $osj2Dresumes->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
	}

	// Call Row Selecting event
	$osj2Dresumes->Row_Selecting($sFilter);

	// Load sql based on filter
	$osj2Dresumes->CurrentFilter = $sFilter;
	$sSql = $osj2Dresumes->SQL();
	if ($rs = $conn->Execute($sSql)) {
		if ($rs->EOF) {
			$LoadRow = FALSE;
		} else {
			$LoadRow = TRUE;
			$rs->MoveFirst();
			LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$osj2Dresumes->Row_Selected($rs);
		}
		$rs->Close();
	} else {
		$LoadRow = FALSE;
	}
	return $LoadRow;
}

// Load row values from recordset
function LoadRowValues(&$rs) {
	global $osj2Dresumes;
	$osj2Dresumes->resume_id->setDbValue($rs->fields('resume_id'));
	$osj2Dresumes->user_id->setDbValue($rs->fields('user_id'));
	$osj2Dresumes->resume_permissions_id->setDbValue($rs->fields('resume_permissions_id'));
	$osj2Dresumes->resume_creation_date->setDbValue($rs->fields('resume_creation_date'));
	$osj2Dresumes->resume_edit_date->setDbValue($rs->fields('resume_edit_date'));
	$osj2Dresumes->resume_text->setDbValue($rs->fields('resume_text'));
	$osj2Dresumes->resume_file->Upload->DbValue = $rs->fields('resume_file');
	$osj2Dresumes->resume_categories->setDbValue($rs->fields('resume_categories'));
	$osj2Dresumes->resume_title->setDbValue($rs->fields('resume_title'));
}
?>
<?php

// Render row values based on field settings
function RenderRow() {
	global $conn, $Security, $osj2Dresumes;

	// Call Row Rendering event
	$osj2Dresumes->Row_Rendering();

	// Common render codes for all row types
	// user_id

	$osj2Dresumes->user_id->CellCssStyle = "";
	$osj2Dresumes->user_id->CellCssClass = "";

	// resume_permissions_id
	$osj2Dresumes->resume_permissions_id->CellCssStyle = "";
	$osj2Dresumes->resume_permissions_id->CellCssClass = "";

	// resume_creation_date
	$osj2Dresumes->resume_creation_date->CellCssStyle = "";
	$osj2Dresumes->resume_creation_date->CellCssClass = "";

	// resume_edit_date
	$osj2Dresumes->resume_edit_date->CellCssStyle = "";
	$osj2Dresumes->resume_edit_date->CellCssClass = "";

	// resume_text
	$osj2Dresumes->resume_text->CellCssStyle = "";
	$osj2Dresumes->resume_text->CellCssClass = "";

	// resume_file
	$osj2Dresumes->resume_file->CellCssStyle = "";
	$osj2Dresumes->resume_file->CellCssClass = "";

	// resume_categories
	$osj2Dresumes->resume_categories->CellCssStyle = "";
	$osj2Dresumes->resume_categories->CellCssClass = "";

	// resume_title
	$osj2Dresumes->resume_title->CellCssStyle = "";
	$osj2Dresumes->resume_title->CellCssClass = "";
	if ($osj2Dresumes->RowType == EW_ROWTYPE_VIEW) { // View row
	} elseif ($osj2Dresumes->RowType == EW_ROWTYPE_ADD) { // Add row

		// resume_permissions_id
		$osj2Dresumes->resume_permissions_id->EditCustomAttributes = "";
		$arwrk = array();
		$arwrk[] = array("0", "Inactive");
		$arwrk[] = array("1", "Active");
		array_unshift($arwrk, array("", "Please Select"));
		$osj2Dresumes->resume_permissions_id->EditValue = $arwrk;

		// resume_edit_date
		$osj2Dresumes->resume_edit_date->EditCustomAttributes = "";
		$osj2Dresumes->resume_edit_date->CurrentValue = ew_FormatDateTime("CURRENT_TIMESTAMP", 10);

		// resume_text
		$osj2Dresumes->resume_text->EditCustomAttributes = "";
		$osj2Dresumes->resume_text->EditValue = ew_HtmlEncode($osj2Dresumes->resume_text->CurrentValue);

		// resume_file
		$osj2Dresumes->resume_file->EditCustomAttributes = "";
		$osj2Dresumes->resume_file->EditValue = $osj2Dresumes->resume_file->CurrentValue;

		// resume_categories
		$osj2Dresumes->resume_categories->EditCustomAttributes = "";

		// resume_title
		$osj2Dresumes->resume_title->EditCustomAttributes = "";
		$osj2Dresumes->resume_title->EditValue = ew_HtmlEncode($osj2Dresumes->resume_title->CurrentValue);
	} elseif ($osj2Dresumes->RowType == EW_ROWTYPE_EDIT) { // Edit row
	} elseif ($osj2Dresumes->RowType == EW_ROWTYPE_SEARCH) { // Search row
	}

	// Call Row Rendered event
	$osj2Dresumes->Row_Rendered();
}
?>
<?php

// Add record
function AddRow() {
	global $conn, $Security, $osj2Dresumes;

	// Check for duplicate key
	$bCheckKey = TRUE;
	$sFilter = $osj2Dresumes->SqlKeyFilter();
	if (trim(strval($osj2Dresumes->resume_id->CurrentValue)) == "") {
		$bCheckKey = FALSE;
	} else {
		$sFilter = str_replace("@resume_id@", ew_AdjustSql($osj2Dresumes->resume_id->CurrentValue), $sFilter); // Replace key value
	}
	if (!is_numeric($osj2Dresumes->resume_id->CurrentValue)) {
		$bCheckKey = FALSE;
	}
	if ($bCheckKey) {
		$rsChk = $osj2Dresumes->LoadRs($sFilter);
		if ($rsChk && !$rsChk->EOF) {
			$_SESSION[EW_SESSION_MESSAGE] = "Duplicate value for primary key";
			$rsChk->Close();
			return FALSE;
		}
	}
	$rsnew = array();

	// Field user_id
	$osj2Dresumes->user_id->SetDbValueDef(CurrentUserID(), 0);
	$rsnew['user_id'] =& $osj2Dresumes->user_id->DbValue;

	// Field resume_permissions_id
	$osj2Dresumes->resume_permissions_id->SetDbValueDef($osj2Dresumes->resume_permissions_id->CurrentValue, 0);
	$rsnew['resume_permissions_id'] =& $osj2Dresumes->resume_permissions_id->DbValue;

	// Field resume_creation_date
	$osj2Dresumes->resume_creation_date->SetDbValueDef(ew_CurrentDateTime(), ew_CurrentDate());
	$rsnew['resume_creation_date'] =& $osj2Dresumes->resume_creation_date->DbValue;

	// Field resume_edit_date
	$osj2Dresumes->resume_edit_date->SetDbValueDef(ew_UnFormatDateTime($osj2Dresumes->resume_edit_date->CurrentValue, 10), NULL);
	$rsnew['resume_edit_date'] =& $osj2Dresumes->resume_edit_date->DbValue;

	// Field resume_text
	$osj2Dresumes->resume_text->SetDbValueDef($osj2Dresumes->resume_text->CurrentValue, "");
	$rsnew['resume_text'] =& $osj2Dresumes->resume_text->DbValue;

	// Field resume_file
	$osj2Dresumes->resume_file->Upload->SaveToSession(); // Save file value to Session
	if (is_null($osj2Dresumes->resume_file->Upload->Value)) {
		$rsnew['resume_file'] = NULL;	
	} else {
		$rsnew['resume_file'] = $osj2Dresumes->resume_file->Upload->GetBinary();
	}

	// Field resume_categories
	$osj2Dresumes->resume_categories->SetDbValueDef($osj2Dresumes->resume_categories->CurrentValue, "");
	$rsnew['resume_categories'] =& $osj2Dresumes->resume_categories->DbValue;

	// Field resume_title
	$osj2Dresumes->resume_title->SetDbValueDef($osj2Dresumes->resume_title->CurrentValue, "");
	$rsnew['resume_title'] =& $osj2Dresumes->resume_title->DbValue;

	// Call Row Inserting event
	$bInsertRow = $osj2Dresumes->Row_Inserting($rsnew);
	if ($bInsertRow) {

		// Field resume_file
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$AddRow = $conn->Execute($osj2Dresumes->InsertSQL($rsnew));
		$conn->raiseErrorFn = '';
	} else {
		if ($osj2Dresumes->CancelMessage <> "") {
			$_SESSION[EW_SESSION_MESSAGE] = $osj2Dresumes->CancelMessage;
			$osj2Dresumes->CancelMessage = "";
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = "Insert cancelled";
		}
		$AddRow = FALSE;
	}
	if ($AddRow) {
		$osj2Dresumes->resume_id->setDbValue($conn->Insert_ID());
		$rsnew['resume_id'] =& $osj2Dresumes->resume_id->DbValue;

		// Call Row Inserted event
		$osj2Dresumes->Row_Inserted($rsnew);
		WriteAuditTrailOnAdd($rsnew);
	}

	// Field resume_file
	$osj2Dresumes->resume_file->Upload->RemoveFromSession(); // Remove file value from Session
	return $AddRow;
}
?>
<?php

// Write Audit Trail start/end for grid update
function WriteAuditTrailDummy($typ) {
	$table = 'osj-resumes';

	// Write Audit Trail
	$filePfx = "log";
	$curDate = date("Y/m/d");
	$curTime = date("H:i:s");
	$id = ew_ScriptName();
	$user = CurrentUserID();
	$action = $typ;
	ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, "", "", "", "");
}
?>
<?php

// Write Audit Trail (add page)
function WriteAuditTrailOnAdd(&$rs) {
	global $osj2Dresumes;
	$table = 'osj-resumes';

	// Get key value
	$key = "";
	if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
	$key .= $rs['resume_id'];

	// Write Audit Trail
	$filePfx = "log";
	$curDate = date("Y/m/d");
	$curTime = date("H:i:s");
	$id = ew_ScriptName();
	$user = CurrentUserID();
	$action = "A";
	$oldvalue = "";
	foreach (array_keys($rs) as $fldname) {
		if ($osj2Dresumes->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field
			$newvalue = ($osj2Dresumes->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) ? "<MEMO>" : $rs[$fldname]; // Memo Field
			ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue);
		}
	}
}
?>
<?php

// Page Load event
function Page_Load() {

	//echo "Page Load";
}

// Page Unload event
function Page_Unload() {

	//echo "Page Unload";
}
?>
